package com.jx.db137.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * @author jx
 * @version 1.0
 * @Description
 * @date 2024/12/13 14:58
 */
@Component

public class R {
    private int code=200;
    private String msgerr="成功";
    private Map<String,Object> data=new HashMap<>();
    public R addData(String key,Object value){
        this.data.put(key,value);
        return this;
    }

    public R() {
    }

    @Override
    public String toString() {
        return "R{" +
                "code=" + code +
                ", msgerr='" + msgerr + '\'' +
                ", data=" + data +
                '}';
    }

    public R(int code, String msgerr, Map<String, Object> data) {
        this.code = code;
        this.msgerr = msgerr;
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public R setCode(int code) {
        this.code = code;
        return this;
    }

    public String getMsgerr() {
        return msgerr;
    }

    public R setMsgerr(String msgerr) {
        this.msgerr = msgerr;
        return this;
    }

    public Map<String, Object> getData() {
        return data;
    }

    public void setData(Map<String, Object> data) {
        this.data = data;
    }
}
